import 'package:flutter/cupertino.dart';
import 'package:flutter_deer/game/iview/game_search_list_iview.dart';
import 'package:flutter_deer/game/models/game_item_entity.dart';
import 'package:flutter_deer/mvp/base_page_presenter.dart';
import 'package:flutter_deer/net/base_entity.dart';
import 'package:flutter_deer/net/net.dart';
import 'package:flutter_deer/util/other_utils.dart';

class GameSearchListPresenter extends BasePagePresenter<GameSearchListIMvpView> {

  @override
  void initState() {
    // WidgetsBinding.instance.addPostFrameCallback((_) {
    //   asyncRequestNetwork<BaseEntity<List<GameItemEntity>>>(Method.get,
    //     url: HttpApi.footballGameAllList,
    //     onSuccess: (data) {
    //       view.setAllGameItems(data!.data);
    //     },
    //   );
    // });
    WidgetsBinding.instance.addPostFrameCallback((_) {
      view.setGameItems([]);
    });
  }

  Future<dynamic> search(String? name) async{
    WidgetsBinding.instance.addPostFrameCallback((_) {
      asyncRequestNetwork<BaseEntity<List<GameItemEntity>>>(Method.get,
        url: HttpApi.footballGameSearchList.replaceAll("{name}", name.nullSafe),
        onSuccess: (data) {
          view.setGameItems(data!.data);
        },
        onError: (code,msg){

        }
      );
    });
  }


}